home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / MotifLookAndFeel.java < prev    next >
Text File  |  1998-06-30  |  35KB  |  758 lines

  1. /*
  2.  * @(#)MotifLookAndFeel.java    1.84 98/04/14
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.plaf.motif;
  22.  
  23.  
  24. import java.awt.Color;
  25. import java.awt.Font;
  26. import java.awt.event.KeyEvent;
  27. import java.awt.event.InputEvent;
  28.  
  29. import com.sun.java.swing.*;
  30. import com.sun.java.swing.plaf.*;
  31. import com.sun.java.swing.border.*;
  32. import com.sun.java.swing.text.JTextComponent;
  33. import com.sun.java.swing.text.DefaultEditorKit;
  34.  
  35. import com.sun.java.swing.plaf.basic.BasicLookAndFeel;
  36. import com.sun.java.swing.plaf.basic.BasicMarginBorder;
  37. import com.sun.java.swing.plaf.basic.BasicComboBoxRenderer;
  38. import com.sun.java.swing.plaf.basic.BasicComboBoxEditor;
  39.  
  40. /**
  41.  * Implements the Motif Look and Feel.
  42.  * UI classes not implemented specifically for Motif will
  43.  * default to those implemented in Basic.  
  44.  * <p>
  45.  * For the keyboard keys defined for each component in this Look and
  46.  * Feel (L&F), see 
  47.  * <a href="../../doc-files/Key-Motif.html">Component Keystroke Actions for the Motif L&F</a>.
  48.  * <p>
  49.  * Warning: serialized objects of this class will not be compatible with
  50.  * future swing releases.  The current serialization support is appropriate
  51.  * for short term storage or RMI between Swing1.0 applications.  It will
  52.  * not be possible to load serialized Swing1.0 objects with future releases
  53.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  54.  * baseline for the serialized form of Swing objects.
  55.  *
  56.  * @version 1.84 04/14/98
  57.  * @author unknown
  58.  */
  59. public class MotifLookAndFeel extends BasicLookAndFeel
  60. {
  61.     public String getName() {
  62.         return "CDE/Motif";
  63.     }
  64.  
  65.     public String getID() {
  66.         return "Motif";
  67.     }
  68.  
  69.     public String getDescription() {
  70.         return "The CDE/Motif Look and Feel";
  71.     }
  72.  
  73.  
  74.     public boolean isNativeLookAndFeel() {
  75.         String osName = System.getProperty("os.name");
  76.         return (osName != null) && (osName.indexOf("Solaris") != -1);
  77.     }
  78.  
  79.  
  80.     public boolean isSupportedLookAndFeel() {
  81.         return true;
  82.     }
  83.  
  84.  
  85.     /**
  86.      * Load the SystemColors into the defaults table.  The keys
  87.      * for SystemColor defaults are the same as the names of
  88.      * the public fields in SystemColor.  If the table is being
  89.      * created on a native Motif platform we use the SystemColor
  90.      * values, otherwise we create color objects whose values match
  91.      * the default CDE/Motif colors.
  92.      */
  93.     protected void initSystemColorDefaults(UIDefaults table)
  94.     {
  95.         String[] systemColors = {
  96.                   "desktop", "#005C5C", /* Color of the desktop background */
  97.             "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */
  98.         "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */
  99.       "activeCaptionBorder", "#B24D7A", /* Border color for caption (title bar) window borders. */
  100.           "inactiveCaption", "#AEB2C3", /* Color for captions (title bars) when not active. */
  101.       "inactiveCaptionText", "#000000", /* Text color for text in inactive captions (title bars). */
  102.     "inactiveCaptionBorder", "#AEB2C3", /* Border color for inactive caption (title bar) window borders. */
  103.                    "window", "#AEB2C3", /* Default color for the interior of windows */
  104.              "windowBorder", "#AEB2C3", /* ??? */
  105.                "windowText", "#000000", /* ??? */
  106.                      "menu", "#AEB2C3", /* ??? */
  107.                  "menuText", "#000000", /* ??? */
  108.                      "text", "#FFF7E9", /* Text background color */
  109.                  "textText", "#000000", /* Text foreground color */
  110.             "textHighlight", "#000000", /* Text background color when selected */
  111.         "textHighlightText", "#FFF7E9", /* Text color when selected */
  112.          "textInactiveText", "#808080", /* Text color when disabled */
  113.                   "control", "#AEB2C3", /* Default color for controls (buttons, sliders, etc) */
  114.               "controlText", "#000000", /* Default color for text in controls */
  115.          "controlHighlight", "#DCDEE5", /* Highlight color for controls */
  116.        "controlLtHighlight", "#DCDEE5", /* Light highlight color for controls */
  117.             "controlShadow", "#63656F", /* Shadow color for controls */
  118.        "controlLightShadow", "#9397A5", /* Shadow color for controls */           
  119.           "controlDkShadow", "#000000", /* Dark shadow color for controls */
  120.                 "scrollbar", "#AEB2C3", /* Scrollbar ??? color. PENDING(jeff) foreground? background? ?*/
  121.                      "info", "#FFF7E9", /* ??? */
  122.                  "infoText", "#000000"  /* ??? */
  123.         };
  124.  
  125.         loadSystemColors(table, systemColors);
  126.     }
  127.  
  128.  
  129.     protected void initClassDefaults(UIDefaults table)
  130.     {
  131.         super.initClassDefaults(table);
  132.  
  133.         String motifPackageName = "com.sun.java.swing.plaf.motif.";
  134.         Object[] uiDefaults = {
  135.                    "ButtonUI", motifPackageName + "MotifButtonUI",
  136.                  "CheckBoxUI", motifPackageName + "MotifCheckBoxUI",
  137.             "DirectoryPaneUI", motifPackageName + "MotifDirectoryPaneUI",
  138.               "FileChooserUI", motifPackageName + "MotifFileChooserUI",
  139.                     "LabelUI", motifPackageName + "MotifLabelUI",
  140.                   "MenuBarUI", motifPackageName + "MotifMenuBarUI",
  141.                      "MenuUI", motifPackageName + "MotifMenuUI",
  142.                  "MenuItemUI", motifPackageName + "MotifMenuItemUI",
  143.          "CheckBoxMenuItemUI", motifPackageName + "MotifCheckBoxMenuItemUI",
  144.       "RadioButtonMenuItemUI", motifPackageName + "MotifRadioButtonMenuItemUI",
  145.               "RadioButtonUI", motifPackageName + "MotifRadioButtonUI",
  146.              "ToggleButtonUI", motifPackageName + "MotifToggleButtonUI",
  147.                 "PopupMenuUI", motifPackageName + "MotifPopupMenuUI",
  148.               "ProgressBarUI", motifPackageName + "MotifProgressBarUI",
  149.                 "ScrollBarUI", motifPackageName + "MotifScrollBarUI",
  150.                "ScrollPaneUI", motifPackageName + "MotifScrollPaneUI",
  151.                    "SliderUI", motifPackageName + "MotifSliderUI",
  152.                 "SplitPaneUI", motifPackageName + "MotifSplitPaneUI",
  153.                "TabbedPaneUI", motifPackageName + "MotifTabbedPaneUI",
  154.                  "TextAreaUI", motifPackageName + "MotifTextAreaUI",
  155.                 "TextFieldUI", motifPackageName + "MotifTextFieldUI",
  156.             "PasswordFieldUI", motifPackageName + "MotifPasswordFieldUI",
  157.                  "TextPaneUI", motifPackageName + "MotifTextPaneUI",
  158.                "EditorPaneUI", motifPackageName + "MotifEditorPaneUI",
  159.                      "TreeUI", motifPackageName + "MotifTreeUI",
  160.             "InternalFrameUI", motifPackageName + "MotifInternalFrameUI",
  161.               "DesktopPaneUI", motifPackageName + "MotifDesktopPaneUI",
  162.                 "SeparatorUI", motifPackageName + "MotifSeparatorUI",
  163.                "OptionPaneUI", motifPackageName + "MotifOptionPaneUI",
  164.                  "ComboBoxUI", motifPackageName + "MotifComboBoxUI",
  165.               "DesktopIconUI", motifPackageName + "MotifDesktopIconUI",
  166.         };
  167.  
  168.         table.putDefaults(uiDefaults);
  169.     }
  170.  
  171.     protected void initComponentDefaults(UIDefaults table) 
  172.     {
  173.         super.initComponentDefaults(table);
  174.  
  175.         FontUIResource dialogPlain12 = new FontUIResource("Dialog", 
  176.                                                           Font.PLAIN, 12);
  177.         FontUIResource serifPlain12 = new FontUIResource("Serif", 
  178.                                                           Font.PLAIN, 12);
  179.         FontUIResource sansSerifPlain12 = new FontUIResource("SansSerif", 
  180.                                                           Font.PLAIN, 12);
  181.         FontUIResource monospacedPlain12 = new FontUIResource("Monospaced", 
  182.                                                           Font.PLAIN, 12);
  183.         ColorUIResource red = new ColorUIResource(Color.red);
  184.         ColorUIResource black = new ColorUIResource(Color.black);
  185.         ColorUIResource white = new ColorUIResource(Color.white);
  186.         ColorUIResource lightGray = new ColorUIResource(Color.lightGray);
  187.         ColorUIResource controlDarker = new ColorUIResource(147, 151, 165);  // slate blue
  188.         ColorUIResource scrollBarTrack = controlDarker;
  189.         ColorUIResource menuItemPressedBackground = new ColorUIResource(165,165,165);
  190.         ColorUIResource menuItemPressedForeground = new ColorUIResource(0,0,0);
  191.  
  192.  
  193.         Object loweredBevelBorder = new UIDefaults.LazyValue() {
  194.             public Object createValue(UIDefaults table) {
  195.                 return MotifBorderFactory.getLoweredBevelBorder();
  196.             }
  197.         };
  198.  
  199.         Object focusBevelBorder = new UIDefaults.LazyValue() {
  200.             public Object createValue(UIDefaults table) {
  201.                 return new BorderUIResource( new CompoundBorder(
  202.                     MotifBorderFactory.getFocusBorder(),
  203.                     MotifBorderFactory.getLoweredBevelBorder()) );
  204.             }
  205.         };
  206.  
  207.         Object raisedBevelBorder = new UIDefaults.LazyValue() {
  208.             public Object createValue(UIDefaults table) {
  209.                 return MotifBorderFactory.getRaisedBevelBorder();
  210.             }
  211.         };
  212.  
  213.         Object buttonBorder = new UIDefaults.LazyValue() {
  214.             public Object createValue(UIDefaults table) {
  215.                 return new BorderUIResource( new CompoundBorder(
  216.                     MotifBorderFactory.getButtonBorder(),
  217.                     BasicMarginBorder.getMarginBorder()) );
  218.             }
  219.         }; 
  220.         
  221.         Object buttonToggleBorder = new UIDefaults.LazyValue() {
  222.             public Object createValue(UIDefaults table) {
  223.                 return new BorderUIResource( new CompoundBorder(
  224.                     MotifBorderFactory.getToggleButtonBorder(),
  225.                     BasicMarginBorder.getMarginBorder()) );
  226.             }
  227.         };
  228.  
  229.         Object fieldTextBorder = new UIDefaults.LazyValue() {
  230.             public Object createValue(UIDefaults table) {
  231.                 return MotifBorderFactory.getFieldBorder();
  232.             }
  233.         };
  234.  
  235.  
  236.     Object progressBarBorder = new BorderUIResource(
  237.         MotifBorderFactory.getLoweredBevelBorder());
  238.  
  239.  
  240.         Object multilineTextBorder = new UIDefaults.LazyValue() {
  241.             public Object createValue(UIDefaults table) {
  242.                 return BasicMarginBorder.getMarginBorder();
  243.             }
  244.         };
  245.  
  246.         Object menuItemCheckIcon = new UIDefaults.LazyValue() {
  247.             public Object createValue(UIDefaults table) {
  248.                 return MotifIconFactory.getMenuItemCheckIcon();
  249.             }
  250.         };
  251.  
  252.         Object menuItemArrowIcon = new UIDefaults.LazyValue() {
  253.             public Object createValue(UIDefaults table) {
  254.                 return MotifIconFactory.getMenuItemArrowIcon();
  255.             }
  256.         };
  257.  
  258.         Object menuArrowIcon = new UIDefaults.LazyValue() {
  259.             public Object createValue(UIDefaults table) {
  260.                 return MotifIconFactory.getMenuArrowIcon();
  261.             }
  262.         };
  263.  
  264.         Object checkBoxIcon = new UIDefaults.LazyValue() {
  265.             public Object createValue(UIDefaults table) {
  266.                 return MotifIconFactory.getCheckBoxIcon();
  267.             }
  268.         };
  269.  
  270.         Object radioButtonIcon = new UIDefaults.LazyValue() {
  271.             public Object createValue(UIDefaults table) {
  272.                 return MotifIconFactory.getRadioButtonIcon();
  273.             }
  274.         };
  275.  
  276.         Object unselectedTabBackground = new UIDefaults.LazyValue() {
  277.             public Object createValue(UIDefaults table) { 
  278.                 Color c = (Color)table.get("control");
  279.                 return new ColorUIResource(Math.max((int)(c.getRed()*.85),0), 
  280.                                            Math.max((int)(c.getGreen()*.85),0), 
  281.                                            Math.max((int)(c.getBlue()*.85),0));
  282.             }
  283.         };
  284.  
  285.         Object unselectedTabForeground = new UIDefaults.LazyValue() {
  286.             public Object createValue(UIDefaults table) { 
  287.                 Color c = (Color)table.get("controlText");
  288.                 return new ColorUIResource(Math.max((int)(c.getRed()*.85),0), 
  289.                                            Math.max((int)(c.getGreen()*.85),0), 
  290.                                            Math.max((int)(c.getBlue()*.85),0));
  291.             }
  292.         };
  293.  
  294.         Object unselectedTabShadow = new UIDefaults.LazyValue() {
  295.             public Object createValue(UIDefaults table) { 
  296.                 Color c = (Color)table.get("control");
  297.                 Color base = new Color(Math.max((int)(c.getRed()*.85),0), 
  298.                                        Math.max((int)(c.getGreen()*.85),0), 
  299.                                        Math.max((int)(c.getBlue()*.85),0));
  300.                 return new ColorUIResource(base.darker());
  301.             }
  302.         };
  303.  
  304.         Object unselectedTabHighlight = new UIDefaults.LazyValue() {
  305.             public Object createValue(UIDefaults table) { 
  306.                 Color c = (Color)table.get("control");
  307.                 Color base = new Color(Math.max((int)(c.getRed()*.85),0), 
  308.                                        Math.max((int)(c.getGreen()*.85),0), 
  309.                                        Math.max((int)(c.getBlue()*.85),0));
  310.                 return new ColorUIResource(base.brighter());
  311.             }
  312.         };
  313.  
  314.     // *** Text
  315.  
  316.     JTextComponent.KeyBinding[] fieldBindings = {
  317.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 
  318.                                  InputEvent.CTRL_MASK),
  319.                       DefaultEditorKit.copyAction),
  320.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 
  321.                                  InputEvent.SHIFT_MASK),
  322.                       DefaultEditorKit.pasteAction),
  323.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 
  324.                                  InputEvent.SHIFT_MASK),
  325.                       DefaultEditorKit.cutAction),
  326.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_F, 
  327.                                  InputEvent.CTRL_MASK),
  328.                       DefaultEditorKit.forwardAction),
  329.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_B, 
  330.                                  InputEvent.CTRL_MASK),
  331.                       DefaultEditorKit.backwardAction),
  332.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_D, 
  333.                                  InputEvent.CTRL_MASK),
  334.                       DefaultEditorKit.deleteNextCharAction),
  335.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  336.                                  InputEvent.SHIFT_MASK),
  337.                       DefaultEditorKit.selectionBackwardAction),
  338.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  339.                                  InputEvent.SHIFT_MASK),
  340.                       DefaultEditorKit.selectionForwardAction),
  341.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  342.                                  InputEvent.CTRL_MASK),
  343.                       DefaultEditorKit.previousWordAction),
  344.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  345.                                  InputEvent.CTRL_MASK),
  346.                       DefaultEditorKit.nextWordAction),
  347.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  348.                                  InputEvent.CTRL_MASK | 
  349.                                  InputEvent.SHIFT_MASK),
  350.                       DefaultEditorKit.selectionPreviousWordAction),
  351.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  352.                                  InputEvent.CTRL_MASK |
  353.                                  InputEvent.SHIFT_MASK),
  354.                       DefaultEditorKit.selectionNextWordAction),
  355.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, 
  356.                                  InputEvent.CTRL_MASK),
  357.                       DefaultEditorKit.selectAllAction),
  358.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0),
  359.                       DefaultEditorKit.beginLineAction),
  360.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
  361.                       DefaultEditorKit.endLineAction),
  362.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 
  363.                                  InputEvent.SHIFT_MASK),
  364.                       DefaultEditorKit.selectionBeginLineAction),
  365.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END, 
  366.                                  InputEvent.SHIFT_MASK),
  367.                       DefaultEditorKit.selectionEndLineAction),
  368.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
  369.                       JTextField.notifyAction)
  370.     };
  371.  
  372.     JTextComponent.KeyBinding[] multilineBindings = {
  373.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 
  374.                                  InputEvent.CTRL_MASK),
  375.                       DefaultEditorKit.copyAction),
  376.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 
  377.                                  InputEvent.SHIFT_MASK),
  378.                       DefaultEditorKit.pasteAction),
  379.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 
  380.                                  InputEvent.SHIFT_MASK),
  381.                       DefaultEditorKit.cutAction),
  382.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_F, 
  383.                                  InputEvent.CTRL_MASK),
  384.                       DefaultEditorKit.forwardAction),
  385.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_B, 
  386.                                  InputEvent.CTRL_MASK),
  387.                       DefaultEditorKit.backwardAction),
  388.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_D, 
  389.                                  InputEvent.CTRL_MASK),
  390.                       DefaultEditorKit.deleteNextCharAction),
  391.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_N,
  392.                                  InputEvent.CTRL_MASK),
  393.                       DefaultEditorKit.downAction),
  394.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_P,
  395.                                  InputEvent.CTRL_MASK),
  396.                       DefaultEditorKit.upAction),
  397.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  398.                                  InputEvent.SHIFT_MASK),
  399.                       DefaultEditorKit.selectionBackwardAction),
  400.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  401.                                  InputEvent.SHIFT_MASK),
  402.                       DefaultEditorKit.selectionForwardAction),
  403.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  404.                                  InputEvent.CTRL_MASK),
  405.                       DefaultEditorKit.previousWordAction),
  406.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  407.                                  InputEvent.CTRL_MASK),
  408.                       DefaultEditorKit.nextWordAction),
  409.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 
  410.                                  InputEvent.CTRL_MASK | 
  411.                                  InputEvent.SHIFT_MASK),
  412.                       DefaultEditorKit.selectionPreviousWordAction),
  413.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 
  414.                                  InputEvent.CTRL_MASK |
  415.                                  InputEvent.SHIFT_MASK),
  416.                       DefaultEditorKit.selectionNextWordAction),
  417.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, 
  418.                                  InputEvent.CTRL_MASK),
  419.                       DefaultEditorKit.selectAllAction),
  420.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0),
  421.                       DefaultEditorKit.beginLineAction),
  422.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
  423.                       DefaultEditorKit.endLineAction),
  424.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 
  425.                                  InputEvent.SHIFT_MASK),
  426.                       DefaultEditorKit.selectionBeginLineAction),
  427.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_END, 
  428.                                  InputEvent.SHIFT_MASK),
  429.                       DefaultEditorKit.selectionEndLineAction),
  430.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0),
  431.                       DefaultEditorKit.upAction),
  432.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
  433.                       DefaultEditorKit.downAction),
  434.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
  435.                       DefaultEditorKit.pageUpAction),
  436.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
  437.                       DefaultEditorKit.pageDownAction),
  438.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_UP,
  439.                                  InputEvent.SHIFT_MASK),
  440.                       DefaultEditorKit.selectionUpAction),
  441.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,
  442.                                  InputEvent.SHIFT_MASK),
  443.                       DefaultEditorKit.selectionDownAction),
  444.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),
  445.                       DefaultEditorKit.insertBreakAction),
  446.         new JTextComponent.KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0),
  447.                       DefaultEditorKit.insertTabAction)
  448.     };
  449.  
  450.         // *** Tree
  451.  
  452.         Object treeOpenIcon = LookAndFeel.makeIcon(getClass(), 
  453.                                                            "icons/TreeOpen.gif");
  454.  
  455.         Object treeClosedIcon = LookAndFeel.makeIcon(getClass(), 
  456.                                                              "icons/TreeClosed.gif");
  457.  
  458.         Object treeLeafIcon = new UIDefaults.LazyValue() {
  459.             public Object createValue(UIDefaults table) {
  460.                 return MotifTreeCellRenderer.loadLeafIcon();
  461.             }
  462.         };
  463.  
  464.         Object treeExpandedIcon = new UIDefaults.LazyValue() {
  465.             public Object createValue(UIDefaults table) {
  466.                 return MotifTreeUI.MotifExpandedIcon.createExpandedIcon();
  467.             }
  468.         };
  469.  
  470.         Object treeCollapsedIcon = new UIDefaults.LazyValue() {
  471.             public Object createValue(UIDefaults table) {
  472.                 return MotifTreeUI.MotifCollapsedIcon.createCollapsedIcon();
  473.             }
  474.         };
  475.  
  476.  
  477.         Object comboBoxRendererActiveValue  = new UIDefaults.ActiveValue() {
  478.             public Object createValue(UIDefaults table) {
  479.                 return new MotifComboBoxRenderer.UIResource();
  480.             }
  481.         };
  482.  
  483.         Object comboBoxEditorActiveValue  = new UIDefaults.ActiveValue() {
  484.             public Object createValue(UIDefaults table) {
  485.                 return new BasicComboBoxEditor.UIResource();
  486.             }
  487.         };
  488.  
  489.         Object menuBarBorder = new UIDefaults.LazyValue(){
  490.           public Object createValue(UIDefaults table) {
  491.             return MotifBorderFactory.getMenuBarBorder();
  492.             // implements UIResource
  493.           }
  494.         };
  495.  
  496.         Object menuMarginBorder = new UIDefaults.LazyValue() {
  497.             public Object createValue(UIDefaults table) {
  498.                 return new BorderUIResource(new CompoundBorder(
  499.                        MotifBorderFactory.getLoweredBevelBorder(),
  500.                        BasicMarginBorder.getMarginBorder()) );
  501.             }
  502.         };
  503.  
  504.         Object popupMenuBorder = new UIDefaults.LazyValue(){
  505.           public Object createValue(UIDefaults table) {
  506.             return new BorderUIResource(MotifBorderFactory.getRaisedBevelBorder());
  507.           }
  508.         };
  509.         Object focusCellHighlightBorder = new BorderUIResource( 
  510.                                               new LineBorder((Color)table.get("activeCaptionBorder")) );
  511.  
  512.         Object[] defaults = {
  513.  
  514.             "Desktop.background", table.get("desktop"),
  515.  
  516.             "Panel.background", table.get("control"),
  517.             "Panel.foreground", table.get("textText"),
  518.             "Panel.font", dialogPlain12,
  519.  
  520.             "ProgressBar.foreground", controlDarker,
  521.         "ProgressBar.border", progressBarBorder,
  522.             "ProgressBar.cellLength", new Integer(9),
  523.             "ProgressBar.cellSpacing", new Integer(0),
  524.  
  525.             "Button.border", buttonBorder,
  526.             "Button.background", table.get("control"),
  527.             "Button.foreground", table.get("controlText"),
  528.             "Button.focus", table.get("controlText"),
  529.             "Button.pressed", table.get("controlLightShadow"),
  530.             "Button.font", dialogPlain12,
  531.  
  532.             "Button.shadow", controlDarker,
  533.  
  534.  
  535.             "RadioButton.background", table.get("control"),
  536.             "RadioButton.foreground", table.get("controlText"),
  537.             "RadioButton.font", dialogPlain12,
  538.             "RadioButton.icon", radioButtonIcon,
  539.             "RadioButton.focus", table.get("activeCaptionBorder"),
  540.             "RadioButton.icon", radioButtonIcon,
  541.  
  542.             "CheckBox.icon", checkBoxIcon,
  543.             "CheckBox.focus", table.get("activeCaptionBorder"),
  544.  
  545.             "RadioButtonMenuItem.icon", radioButtonIcon,
  546.             "CheckBoxMenuItem.icon", checkBoxIcon,
  547.  
  548.             "ToggleButton.border", buttonToggleBorder,
  549.             "ToggleButton.background", table.get("control"),
  550.             "ToggleButton.foreground", table.get("controlText"),
  551.             "ToggleButton.focus", table.get("controlText"),
  552.             "ToggleButton.selected",  table.get("controlLightShadow"),
  553.             "ToggleButton.pressed", table.get("controlLightShadow"),
  554.             "ToggleButton.font", dialogPlain12,
  555.  
  556.             "Menu.border", menuMarginBorder,
  557.             "Menu.font", dialogPlain12,
  558.             "Menu.foreground", table.get("menuText"),
  559.             "Menu.background", table.get("menu"),
  560.             "Menu.pressedForeground", menuItemPressedForeground,
  561.             "Menu.pressedBackground", menuItemPressedBackground,
  562.             "Menu.arrowIcon", menuArrowIcon,
  563.  
  564.             "MenuBar.border", menuBarBorder,
  565.             "MenuBar.background", table.get("menu"),
  566.             "MenuBar.foreground", table.get("menuText"),
  567.             "MenuBar.font", dialogPlain12,
  568.  
  569.             "MenuItem.border", menuMarginBorder,
  570.             "MenuItem.font", dialogPlain12,
  571.             "MenuItem.acceleratorFont", dialogPlain12,
  572.             "MenuItem.foreground", table.get("menuText"),
  573.             "MenuItem.background", table.get("menu"),
  574.             "MenuItem.pressedForeground", menuItemPressedForeground,
  575.             "MenuItem.pressedBackground", menuItemPressedBackground,
  576.             "MenuItem.checkIcon", menuItemCheckIcon,
  577.             "MenuItem.arrowIcon", menuItemArrowIcon,
  578.  
  579.             "PopupMenu.background", table.get("menu"),
  580.             "PopupMenu.border", popupMenuBorder,            
  581.             "PopupMenu.foreground", table.get("menuText"),
  582.             "PopupMenu.font", dialogPlain12,
  583.  
  584.             "Label.font", dialogPlain12,
  585.             "Label.background", table.get("control"),
  586.             "Label.foreground", table.get("controlText"),
  587.  
  588.             "List.focusCellHighlightBorder", focusCellHighlightBorder,
  589.  
  590.             "DesktopIcon.icon", LookAndFeel.makeIcon(getClass(), 
  591.                                                              "icons/DesktopIcon.gif"),
  592.  
  593.             "ScrollBar.background", scrollBarTrack,
  594.             "ScrollBar.foreground", table.get("control"),
  595.             "ScrollBar.track", scrollBarTrack,
  596.             "ScrollBar.trackHighlight", table.get("controlDkShadow"),
  597.             "ScrollBar.thumb", table.get("control"),
  598.             "ScrollBar.thumbHighlight", table.get("controlHighlight"),
  599.             "ScrollBar.thumbDarkShadow", table.get("controlDkShadow"),
  600.             "ScrollBar.thumbLightShadow", table.get("controlShadow"),
  601.             "ScrollBar.border", loweredBevelBorder,
  602.  
  603.             "ScrollPane.border", null,
  604.             "ScrollPane.font", dialogPlain12,
  605.             "ScrollPane.background", table.get("control"),
  606.             "ScrollPane.foreground", table.get("controlText"),
  607.             "ScrollPane.viewportBorder", loweredBevelBorder,
  608.  
  609.             "Slider.border", focusBevelBorder,
  610.             "Slider.foreground", table.get("control"),
  611.             "Slider.background", controlDarker,
  612.             "Slider.highlight", table.get("controlHighlight"),
  613.             "Slider.shadow", table.get("controlShadow"),
  614.             "Slider.focus", table.get("controlDkShadow"),
  615.  
  616.             "SplitPane.background", table.get("control"),
  617.             "SplitPane.highlight", table.get("controlHighlight"),
  618.             "SplitPane.shadow", table.get("controlShadow"),
  619.         "SplitPane.dividerSize", new Integer(18),
  620.  
  621.             "TabbedPane.font", dialogPlain12,
  622.             "TabbedPane.tabBackground", table.get("control"),
  623.             "TabbedPane.tabForeground", table.get("controlText"),
  624.             "TabbedPane.tabHighlight", table.get("controlHighlight"),
  625.             "TabbedPane.tabShadow", table.get("controlShadow"),
  626.             "TabbedPane.unselectedTabBackground", unselectedTabBackground,
  627.             "TabbedPane.unselectedTabForeground", unselectedTabForeground,
  628.             "TabbedPane.unselectedTabHighlight", unselectedTabHighlight,
  629.             "TabbedPane.unselectedTabShadow", unselectedTabShadow,
  630.             "TabbedPane.focus", table.get("activeCaptionBorder"),
  631.  
  632.  
  633.             "Tree.background", controlDarker,                              // default: dark slate blue
  634.             "Tree.hash", table.get("controlDkShadow"),                     // default: black
  635.             "Tree.iconShadow", table.get("controlShadow"),
  636.             "Tree.iconHighlight", table.get("controlHighlight"),
  637.             "Tree.iconBackground", table.get("control"),                              
  638.             "Tree.iconForeground", table.get("controlShadow"),             // default: black
  639.             "Tree.borderSelectionColor", table.get("activeCaptionBorder"), // default: maroon
  640.             "Tree.textSelectionColor", table.get("textText"),              // default: black
  641.             "Tree.textNonSelectionColor", table.get("textText"),           // default: black
  642.             "Tree.backgroundSelectionColor", table.get("text"),            // default: white
  643.             "Tree.backgroundNonSelectionColor", controlDarker,             // default: dark slate blue
  644.             "Tree.backgroundNonSelectionColor", controlDarker,             // default: dark slate blue
  645.             "Tree.openIcon", treeOpenIcon,
  646.             "Tree.closedIcon", treeClosedIcon,
  647.             "Tree.leafIcon", treeLeafIcon,
  648.             "Tree.expandedIcon", treeExpandedIcon,
  649.             "Tree.collapsedIcon", treeCollapsedIcon,
  650.  
  651.             "Table.focusCellHighlightBorder", focusCellHighlightBorder,
  652.             "Table.scrollPaneBorder", null,
  653.  
  654.             //      "Table.background", white,  // cell background color
  655.             //      "Table.focusCellBackground", white,
  656.  
  657.  
  658.  
  659.             "ComboBox.control", table.get("control"),
  660.             "ComboBox.controlForeground", black,
  661.             "ComboBox.renderer", comboBoxRendererActiveValue,
  662.             "ComboBox.editor",   comboBoxEditorActiveValue,
  663.             "ComboBox.background", table.get("window"), 
  664.             "ComboBox.foreground", black,
  665.             "ComboBox.selectedBackground", black,
  666.             "ComboBox.selectedForeground", table.get("text"),
  667.             "ComboBox.disabledBackground", table.get("control"),
  668.             "ComboBox.disabledForeground", table.get("textInactiveText"),
  669.             "ComboBox.font", dialogPlain12,
  670.  
  671.             "TextField.caretForeground", black,
  672.             "TextField.caretBlinkRate", new Integer(500),
  673.             "TextField.inactiveForeground", table.get("textInactiveText"),
  674.             "TextField.selectionBackground", table.get("textHighlight"),
  675.             "TextField.selectionForeground", table.get("textHighlightText"),
  676.             "TextField.background", table.get("window"),
  677.             "TextField.foreground", table.get("textText"),
  678.             "TextField.font", sansSerifPlain12,
  679.             "TextField.border", fieldTextBorder,
  680.         "TextField.keyBindings", fieldBindings,
  681.             
  682.             "PasswordField.caretForeground", black,
  683.             "PasswordField.caretBlinkRate", new Integer(500),
  684.             "PasswordField.inactiveForeground", table.get("textInactiveText"),
  685.             "PasswordField.selectionBackground", table.get("textHighlight"),
  686.             "PasswordField.selectionForeground", table.get("textHighlightText"),
  687.             "PasswordField.background", table.get("window"),
  688.             "PasswordField.foreground", table.get("textText"),
  689.             "PasswordField.font", monospacedPlain12,
  690.             "PasswordField.border", fieldTextBorder,
  691.         "PasswordField.keyBindings", fieldBindings,
  692.             
  693.             "TextArea.caretForeground", black,
  694.             "TextArea.caretBlinkRate", new Integer(500),
  695.             "TextArea.inactiveForeground", table.get("textInactiveText"),
  696.             "TextArea.selectionBackground", table.get("textHighlight"),
  697.             "TextArea.selectionForeground", table.get("textHighlightText"),
  698.             "TextArea.background", table.get("window"),
  699.             "TextArea.foreground", table.get("textText"),
  700.             "TextArea.font", monospacedPlain12,
  701.             "TextArea.border", multilineTextBorder,
  702.         "TextArea.keyBindings", multilineBindings,
  703.             
  704.             "TextPane.caretForeground", black,
  705.             "TextPane.caretBlinkRate", new Integer(500),
  706.             "TextPane.inactiveForeground", table.get("textInactiveText"),
  707.             "TextPane.selectionBackground", lightGray,
  708.             "TextPane.selectionForeground", table.get("textHighlightText"),
  709.             "TextPane.background", white,
  710.             "TextPane.foreground", table.get("textText"),
  711.             "TextPane.font", serifPlain12,
  712.             "TextPane.border", multilineTextBorder,
  713.         "TextPane.keyBindings", multilineBindings,
  714.             
  715.             "EditorPane.caretForeground", red,
  716.             "EditorPane.caretBlinkRate", new Integer(500),
  717.             "EditorPane.inactiveForeground", table.get("textInactiveText"),
  718.             "EditorPane.selectionBackground", lightGray,
  719.             "EditorPane.selectionForeground", table.get("textHighlightText"),
  720.             "EditorPane.background", white,
  721.             "EditorPane.foreground", table.get("textText"),
  722.             "EditorPane.font", serifPlain12,
  723.             "EditorPane.border", multilineTextBorder,
  724.         "EditorPane.keyBindings", multilineBindings,
  725.  
  726.         "FileChooser.acceptAllFileFilterText", new String ("*"),
  727.             "FileChooser.cancelButtonText", new String("Cancel"),
  728.             "FileChooser.saveButtonText", new String("Save"),
  729.             "FileChooser.openButtonText", new String("OK"),
  730.             "FileChooser.updateButtonText", new String("Update"),
  731.             "FileChooser.helpButtonText", new String("Help"),
  732.  
  733.             "FileChooser.cancelButtonToolTipText", new String("Abort file chooser dialog."),
  734.             "FileChooser.saveButtonToolTipText", new String("Save selected file."),
  735.             "FileChooser.openButtonToolTipText", new String("Open selected file."),
  736.             "FileChooser.updateButtonToolTipText", new String("Update directory listing."),
  737.             "FileChooser.helpButtonToolTipText", new String("FileChooser help."),
  738.  
  739.             "ToolTip.border", raisedBevelBorder,
  740.             "ToolTip.background", table.get("info"),
  741.             "ToolTip.foreground", table.get("infoText"),
  742.  
  743.             "OptionPane.errorIcon", LookAndFeel.makeIcon(getClass(), 
  744.                                                          "icons/Error.gif"),
  745.             "OptionPane.informationIcon", LookAndFeel.makeIcon(getClass(), 
  746.                                                                "icons/Inform.gif"),
  747.             "OptionPane.warningIcon", LookAndFeel.makeIcon(getClass(), 
  748.                                                            "icons/Warn.gif"),
  749.             "OptionPane.questionIcon", LookAndFeel.makeIcon(getClass(), 
  750.                                                             "icons/Question.gif")
  751.         };
  752.  
  753.         table.putDefaults(defaults);
  754.     }
  755.  
  756. }
  757.  
  758.